import React, { FC, useReducer, useState } from "react"



// 根据传入的action返回新的state（不可变数据）


const CountReducer: FC = () => {
  //   const [count, setCount] = useState(100)
  //   dispatch是用于修改数据的派发函数
  const [state, dispatch] = useReducer(reducer, initialState)

  return (
    <>
      <span>count:{state.count}</span>
      {/* <button onClick={() => setCount(count + 1)}>+</button>
      <button onClick={() => setCount(count - 1)}>-</button> */}
      <button onClick={() => dispatch({ type: "increment" })}>+</button>
      <button onClick={() => dispatch({ type: "decrement" })}>-</button>
    </>
  )
}

export default CountReducer
